package leecode

func numSubarrayProductLessThanKLCR(nums []int, k int) (result int) {
	if k <= 1 {
		return
	}
	left, right := 0, 0
	temp := 1
	for right < len(nums) {
		temp = temp * nums[right]
		for temp >= k {
			//回溯
			temp = temp / nums[left]
			left++
		}
		//只要乘积小于k 窗口就一直右移
		result += right - left + 1
		right++
	}
	return result
}
